<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>给画布应用变换</title>
        <meta name="auther" content="wangjiale"/>
        <style>
            canvas{border:thin solid black; margin:4px;}
            body>*{float:left;}
        </style>
    </head>
    <body>
        <canvas id="canvas" width="400" height="200">
            Your browser doesn't support the <code>canvas</code> element.
        </canvas>
        <script>
            var ctx=document.getElementById("canvas").getContext("2d");
            ctx.fillStyle="lightgrey";
            ctx.strokeStyle="black";
            ctx.lineWidth=3;

            ctx.clearRect(0,0,300,120);
            ctx.globalAlpha=1.0;
            ctx.font="100px sans-serif";
            ctx.fillText("Hello",10,100);
            ctx.strokeText("Hello",10,100);

            ctx.scale(1.5,1.5);
            ctx.translate(100,-50);
            ctx.rotate(0.5);

            ctx.fillStyle="red";
            ctx.strokeStyle="green";
            ctx.globalAlpha=0.5;
            ctx.fillRect(100,10,150,100);
            ctx.strokeRect(0,0,300,200);
        </script>
    </body>
</html>